<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>编辑模板设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" type="text/css" href="css/main.css" />
  <link rel="stylesheet" type="text/css" href="../mobile/js/layer/css/layui.css"/>
  <link rel="stylesheet" type="text/css" href="css/style.css" />
  <script src="./js/jquery-1.9.1.js"></script>
  <script src="../mobile/js/layer/layui.js"></script>
  <script src="./js/common.js"></script>
</head>
<body>
<div style="margin: -30px 20px 20px 20px;">
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;cursor: pointer;" onclick="window.location.href='setting_template.html'">
  <legend>模板设置</legend>
</fieldset>
<blockquote class="layui-elem-quote">
   <button class="layui-btn btns"><i class="layui-icon" style="color: #fff">&#xe642;</i>编辑模板设置</button>
</blockquote>
    <div class="x-body layui-anim layui-anim-up">
        <form method="post" class="layui-form">
          <div class="layui-form-item">
              <label for="L_smsform" class="layui-form-label">
                  <span class="x-red">*</span>模板内容
              </label>
              <div class="layui-input-block">
                  <textarea placeholder="请输入内容" id="L_smsform" name="smsform" class="layui-textarea"  lay-verify="smsform"
                  autocomplete="off" style="width:90%" required></textarea>
              </div>
              <br>
              <div class="layui-form-mid layui-word-aux" style="margin-left:36px;">
                  <span class="x-red">*</span>格式为:***{$device_id}***{$flow},***(***表示文字)
              </div>
          </div>
         <!--  <div class="layui-form-item">
               <label for="L_type" class="layui-form-label" style="margin-left: -8px;" name="status">
                  <span class="x-red">*</span>启用状态
              </label>
            <div class="layui-input-inline">
              <input type="checkbox" name="status" lay-skin="switch" id="status" lay-text="开启|关闭" checked>
            </div>
            <div class="layui-form-mid layui-word-aux" style="margin-left: -135px;">
                  <span class="x-red">*</span>是否启用该短信平台
            </div>
          </div> -->
          <div class="layui-form-item" style="text-align: center;margin-left: -150px;">
             <label for="L_repass" class="layui-form-label">
              </label>
              <button  type="submit" class="layui-btn btns" lay-filter="editsms" lay-submit="">
                  编辑
              </button>
          </div>
      </form>
    </div>
</div>    
<script>
  var urls = url + "/admin/config/editsmslist";
  var id = new Object();
  id = GetRequest();
  id = id.id;
  $.ajax({
    type: 'get',
    dataType: 'json',
    data:{id:id},
    url:urls,
    success:function(msg){
      if(msg.code == 1){
         $("#L_smsform").val(msg.data.smsform);
      }
    }
  })
  layui.use(['form','layer','layedit'], function(){
    var form = layui.form
    ,layer = layui.layer
    ,$ = layui.jquery;
  
    //自定义验证规则
    form.verify({
      smsform: [/(.+){1,255}$/, '内容必须1~255个字符']
    });
    //监听提交
    form.on('submit(editsms)', function(data){
      var urls = url + "/admin/config/editsms";
      var id = new Object();
      id = GetRequest();
      data.field.id = id.id;
      $.post(urls,data.field,function(msg){
          var msg = JSON.parse(msg);
          if(msg.code == 1){
             layer.alert(msg.infomsg, {icon: 6},function () {
               window.location.href = 'setting_template.html';
             });
          }else{
             layer.alert(msg.infomsg, {icon: 5}); 
          }
      })
        return false;
    });   
  });
</script>
</body>
</html>